/*
 * Copyright 2010-2012 Susanta Tewari. <freecode4susant@users.sourceforge.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package genomemap.cef.pui;

import cef.event.ComputeLHoodWEstEvent;
import cef.event.Event;
import cef.pui.EventConstructionException;
import cef.pui.EventImpl;
import cef.pui.pob.Builder;
import cef.pui.pob.BuilderException;
import commons.core.LikelihoodComputer;
import commons.core.ModelEstimator;
import genomemap.cef.pui.pob.Builders_Gen;
import genomemap.data.KSA00Data;
import genomemap.model.KSA00;

import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

/**
 * Implements {@code ComputeKSA00Likelihood_Evt} using the following properties. <ul> <li>{@code
 * genomemap.builder.KSA00Data.url = ksa00data:xml//URL }<a href="genomemap/cef/pui/pob/doc-files/ksa00-data.xml.txt">file
 * format</a>, must accompany the <a href="genomemap/cef/pui/pob/doc-files/KSA00Data.xsd.txt">schema</a></li>
 * <li>{@code genomemap.builder.KSA00Lhood.implCode = ksa00:1}</li>
 * <li>{@code genomemap.builder.KSA00Estimator.implCode = ksa00estimator:conj-gradient}</li></ul>
 *
 * @author Susanta Tewari
 * @version 1.0.0
 * @history Created on 10/27/2012
 * @since 1.0.0
 */
public final class ComputeKSA00LHoodWEstEventImpl extends EventImpl
        implements ComputeLHoodWEstEvent<KSA00, KSA00Data> {

    /** Field description */
    private final Builder<KSA00Data> dataBuilder;

    /** Field description */
    private final Builder<ModelEstimator<KSA00, KSA00Data, KSA00Data, ?>> estimatorBuilder;

    /** Field description */
    private final Builder<LikelihoodComputer<KSA00Data>> lhoodBuilder;

    /**
     * Constructs ...
     *
     *
     * @param props
     *
     * @throws EventConstructionException
     */
    public ComputeKSA00LHoodWEstEventImpl(final Properties props)
            throws EventConstructionException {

        super(props);

        super.processEventProperties(getImplementedEventInterfaces());


        // data builder
        dataBuilder = Builders_Gen.of_Data_KSA00_File(props, null);


        // estimator builder
        estimatorBuilder = Builders_Gen.of_ModelEstimator_KSA00(props, null);


        // add lhood builder
        lhoodBuilder = Builders_Gen.of_LHoodComputer_KSA00(props, null);
    }

    /**
     * Method description
     *
     *
     * @return
     */
    @Override
    protected List<Class<? extends cef.event.Event>> getImplementedEventInterfaces() {

        final List<Class<? extends cef.event.Event>> result = new ArrayList<>(2);

        result.add(ComputeLHoodWEstEvent.class);
        result.add(Event.class);

        return result;
    }

    /**
     * {@inheritDoc}
     *
     * @throws cef.pui.pob.BuilderException
     */
    @Override
    public KSA00Data getData() throws BuilderException {
        return dataBuilder.build();
    }

    /**
     * {@inheritDoc}
     *
     * @throws cef.pui.pob.BuilderException
     */
    @Override
    public LikelihoodComputer<KSA00Data> getLikilihoodComputer() throws BuilderException {
        return lhoodBuilder.build();
    }

    @Override
    public ModelEstimator<KSA00, KSA00Data, KSA00Data, ?> getEstimator() {
        return estimatorBuilder.build();
    }
}
